const path = require('path')

const filePath = './temp.txt'

// 完整文件名
const fullFileName = path.basename(filePath)
console.log(fullFileName) // temp.txt

// 文件扩展名
const fileExtension = path.extname(filePath)
console.log(fileExtension) // .txt

// 文件名
const fileName = path.basename(filePath, fileExtension)
console.log(fileName) // temp